<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ include file="../common.jsp" %>

<script type="text/javascript">
	$(document).ready(function(){
		setPageTitle('<tiles:getAsString name="pageTitle"/>');
		/* createLayoutForAddOrEdit('uploadDocNorthPane','uploadDocTabs'); */
		setWorkFlowURL('<c:out value="${flowExecutionUrl}" />');
		remarksDialog=null;
		vaultDetailsDialog=null;
		rejectDocDialog=null;
		createSerachUserDialog();
		$( "#linkedDocId" ).selectable();
	});
</script>
<style type="text/css">
	.formButtonApproval {
	 	color: #FFFFFF;
		border-style: solid;
		border-width: 1px;
		border-spacing: 0px;
		text-align: center;
		font-family: verdana;
	 	font-size: 12px !important;
	}
	
	
</style>
<div align="center" style="overflow: auto;">
	<table class="bodyTable">
		<tr>
			<td>
				<table class="filtersTable zeroBorder" style="width: 100%;">
					<tr class="tableChildHeaderColor" align="left" style="width: 100%;">
						<td>
							<table style="width: 100%;">
								<tr>
									<td style="width: 60%;">
										<table>
											<tr>
												<td class="spacingColumnWidthLess"></td>
												<td align="left">
													<!-- <img alt="" src="./customTheme/Icons/BlueLotus_DMS_icons-11.png"> -->
												</td>
												<td class="spacingColumnWidthLess"></td>
												<td style="vertical-align: middle;"><span class="tableMainHeaderFont">APPROVE DOCUMENT</span></td>
											</tr>
										</table>
									</td>
									<td style="width: 40%;">
										<table class="zeroBorder" style="width: 100%;">
											<tr align="right">
												<td >
													<input type="button" class="formButton" value="Back" onclick="javascript:workFlowDetail('docAttrDTO','back');"/>&nbsp;
									 				<input type="button" class="formButtonApproval" style="background-color: green; color: white; border-color: green; " value="Confirm" onclick="javascript:approveDocument('approve');"/>&nbsp;
									 				<input type="button" class="formButtonApproval" style="background-color: red; color: white; border-color: red;" value="Reject" onclick="javascript:approveDocument('reject');"/>&nbsp;
									 				<!-- <input type="button" class="formButton" value="Map Users" onclick="javascript:approveDocument('mapUsers');"/> -->
												</td>
											</tr>
										</table>
									</td>
								</tr>
							</table>
						</td>
					</tr>
					<tr class="formSpacingRow formBlockColor"><td></td></tr>
					<tr>
						<td align="center">
						<div id="uploadDocTabs" class="formBlockColor"  style="overflow: auto;">
							<form:form commandName="docDetailsForm" id="uploadNewDocForm" name="uploadNewDocForm" action="${flowExecutionUrl}" enctype="multipart/form-data" method="POST">
							<form:hidden path="originalDocTypeId" value="-1"/>
							<form:hidden path="docId" value="${docDetailsForm.docId}" id="docId"/>
								<table style="width: 100%;" border="0" class="formTable" >
									
									<tr  align="left">
										<td class="spacingColumnWidthLess">&nbsp;</td>
										<td colspan="3" align="right">
											<div class="ui-corner-all" style="width: 80%; border-style: dotted; border-width:1px; height: 3em; padding: 10px; text-align: left;">
												<span class="formLabel">Attached Document:&nbsp;</span>
												<br><a target="_blank" href="downloadAttachment/${docDetailsForm.docId}.htm">${docDetailsForm.docName}</a>
												
											</div> 
										</td>
										<td class="spacingColumnWidthMedium"></td>
										<td colspan="3" align="left">
											<c:if test='${!fn:contains(currentDocStatus,"RenewWfip")}'>
											<div class="ui-corner-all" style="width: 80%; border-style: dotted; border-width:1px; height: 3em; padding: 10px; overflow: auto;">
												<span class="formLabel">Link Documents&nbsp;
													<a href="#" onclick="javascript:showDocumentLookUpDialog('uploadNewDocForm');" style="text-decoration: none;">
														<img alt=""  src='<c:url value="/customTheme/Icons/BlueLotus_DMS_icons-30.png"></c:url>'>
													</a>
													
													<input class="formButton ui-corner-all" type="button" value="Delete" onclick="deleteDocument()"/>
													<input class="formButton ui-corner-all" type="button" value="Update" onclick="updateDocumentLink('uploadNewDocForm')"/>
												</span>
												<ul id="linkedDocId" class="userListClass">
												<c:forEach items="${linkedDocumentMap}" var="linkedDocumentMap">
													<li id="${linkedDocumentMap.key}" class="ui-state-default">${linkedDocumentMap.value}</li>
													<input type="hidden" name="linkedDocId" id="${linkedDocumentMap.key}" value="${linkedDocumentMap.key}">
												</c:forEach>
												</ul>
													<c:forEach var="linkedDocumentList" items="${linkedDocumentList}">
									    					<input type="hidden" name="oldLinkedDocument" value="${linkedDocumentList}"></input>
									   				</c:forEach>
									   				
											</div>
											</c:if>
										</td>
										<td class="spacingColumnWidthLess"></td>
									</tr>

									<tr class="formSpacingRow formBlockColor">
										<td colspan="9">
											<hr>
										</td>
									</tr>
									
									<tiles:insertAttribute name="viewAttrDetails"></tiles:insertAttribute>
									<tr class="formSpacingRow formBlockColor">
										<td colspan="9">
											<hr>
										</td>
									</tr>
									
									<tiles:insertAttribute name="viewOwnerDetails"></tiles:insertAttribute>
									
									<tr class="formSpacingRow formBlockColor">
										<td colspan="9">
											<hr>
										</td>
									</tr>
									
									<tiles:insertAttribute name="viewValidityDetails"></tiles:insertAttribute>
									
									 <tr class="formSpacingRow formBlockColor">
										<td colspan="9">
											<hr>
										</td>
									</tr>
									<tr>
										<td class="spacingColumnWidthLess">&nbsp;</td>
										<td colspan="7">
											<div class="ui-corner-all" style="width: 80%; border-style: dotted; border-width:1px; height: 3em; padding: 10px; overflow: auto;">
												<span class="formLabel" style="vertical-align: middle;">Authorized Signatory&nbsp;
												
												<a href="#" onclick="javascript:showUserLookUpDialogForWF('ROLE_AUTHSIGN');" style="text-decoration: none;">
														<img alt=""  src='<c:url value="/customTheme/Icons/BlueLotus_DMS_icons-30.png"></c:url>'>
													</a>
													<input type="button" class="formButton" value="Save" onclick="saveAuthSignatory('uploadNewDocForm')"/>
													</span>
												<ul id="authUserId" class="userListClass">
													<c:forEach items="${authSignList}" var="authSignList">
														<li id="${authSignList.userId}" class='ui-state-default'>${authSignList.userName}</li>
														<input type="hidden" name="linkedDocId" id="${authSignList.userId}" value="${authSignList.userName}">
													</c:forEach>
												</ul>
												<br/>
											</div>
										</td>
									</tr>
								
									<!-- <tr>
										<td colspan="5"></td>
										<td colspan="3" align="right">
											<input type="reset" value="RESET" name="resetForm" class="resetButton">
											<span class="spacingColumnWidthLess">&nbsp;</span>
											<input type="hidden" value="ajaxRequest" name="ajaxSource">
											<input type="button" class="formButton ui-corner-all" value="UPLOAD" onclick="loadContentToServer('uploadNewDocForm','contentDiv')">	
										</td>
										<td class="spacingColumnWidthLess"></td>
									</tr>	 -->												
								</table>
							</form:form>
					</div>
						</td>
				</table>
			</td>
		</tr>
	</table>
</div>


<%-- <div id="uploadDocNorthPane" class="ui-layout-north ui-widget-header">
	<table class="tabsHeaderTable" >
		<tbody valign="middle">
			<tr>
				<td><span>View Document</span></td>
				<td style="width: 25.0em;"></td>
				<td> <input type="button" value="Back" onclick="javascript:workFlowDetail('docAttrDTO','back');"/> </td>
	 			<td> <input type="button" style="background-color: green; color: white;" value="Approve" onclick="javascript:approveDocument('approve');"/> </td>	
				<td> <input type="button" style="background-color: red; color: white;" value="Reject" onclick="javascript:approveDocument('reject');"/> </td>	
				<td> <input type="button" value="Map Users" onclick="javascript:approveDocument('mapUsers');"/> </td>
			</tr>
		</tbody>
	</table>
</div>
	

	<form:form commandName="docDetailsForm" id="uploadNewDocForm" action="${flowExecutionUrl}" enctype="multipart/form-data" method="POST">
		<div id="uploadDocTabs" class="ui-layout-center">
		<table style="width: 90%;">
			<tr>
				<td>
					<table>
						<tiles:insertAttribute name="viewAttrDetails"></tiles:insertAttribute>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<div id="viewDynamicMetaAttr"></div>
				</td>
			</tr>
			<tr>
				<td>
					<hr/>
					<table>
						<tiles:insertAttribute name="viewOwnerDetails"></tiles:insertAttribute>
					</table>
				</td>
			</tr>
			<tr>
				<td>
					<hr/>
					<table>
						<tiles:insertAttribute name="viewValidityDetails"></tiles:insertAttribute>
					</table>
				</td>
			</tr>
			<tr>
				<td>
				<hr/>
					<h5>Linked Documents</h5>
					<div id="linkedDocument">
						
						<ul id="linkedDocId" class="userListClass">
						<c:forEach items="${linkedDocumentMap}" var="linkedDocumentMap">
							<li id="${linkedDocumentMap.key}" class='ui-state-default'>${linkedDocumentMap.value}</li>
							<input type="hidden" name="linkedDocId" id="${linkedDocumentMap.key}" value="${linkedDocumentMap.key}">
						</c:forEach>
						<c:forEach var="linkedDocumentList" items="${linkedDocumentList}">
		     					<input type="hidden" name="oldLinkedDocument" value="${linkedDocumentList}"></input>
		    				</c:forEach>
						</ul>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img alt="" height="40" src="<c:url value="/search.png"></c:url>" onclick="showDocumentLookUpDialog();">
						&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value="Delete" onclick="deleteDocument()"/>
						<input type="button" value="Update Document Link" onclick="updateDocumentLink('uploadNewDocForm')"/>
						<br>&nbsp;<label style="font-size: 0.6em;"> Document Lookup </label>	
						
					</div>
				</td>
			</tr>			
			<tr>
				<td>
					<hr/>
					<h5>Authorized Signatory</h5>
					<div id="authSignDiv">
						<ul id="authUserId" class="userListClass">
						<c:forEach items="${authSignList}" var="authSignList">
							<li id="${authSignList.userId}" class='ui-state-default'>${authSignList.userName}</li>
							<input type="hidden" name="linkedDocId" id="${authSignList.userId}" value="${authSignList.userName}">
						</c:forEach>
							
						</ul><br/>
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img alt="" height="40" src="<c:url value="/search.png"></c:url>" onclick="showUserLookUpDialogForWF('ROLE_AUTHSIGN');">
						<input type="button" value="Save" onclick="saveAuthSignatory('uploadNewDocForm')"/>
						<br>&nbsp;<label style="font-size: 0.6em;"> User Lookup </label>
					</div>
				</td>
			</tr>
		</table>
	</div>	
</form:form> --%>
	
	<sec:authorize ifNotGranted="ROLE_CONTROLLER">
		<div id="remarksDiv" title="Submission Remarks">
		</div>	
	</sec:authorize>
		<div id="vaultDiv"></div>
		<div id="mapUsersDiv" title="Map Users To Document"></div>
		<div id="userSearchDialogue" title="Search User">
				<tiles:insertAttribute name="userSearch"></tiles:insertAttribute>
		</div>